import axios from "axios";
import {message} from "antd";
const authRequest = axios.create({
    baseURL:"/auth"
})
authRequest.interceptors.response.use(({data})=>{
    if(data.code === 200){
        return data;
    }
    message.error(data.message);
    return Promise.reject(data);

})
// 请求拦截
authRequest.interceptors.request.use((config: any) => {
    if (localStorage.getItem('token')) {
        config.headers.token=localStorage.getItem('token');
    }
    return config;
})
export default authRequest;